<?php

namespace App\Admin\Extensions;

use Encore\Admin\Admin;

class FollowList
{
    public function __construct($oid, $name)
    {
        $this->oid = $oid;
        $this->name = $name;
    }
    protected function script()
    {
        return <<<SCRIPT

    layui.use('layer', function(){
        var layer = layui.layer;
        $('.follow').click(function () {
           var that = this;
           var oid = $(that).attr('data-oid');
           var name = $(that).attr('data-name');
           var index = layer.open({
               title: '<\span style="color:red;">'+name+'</\span>',
               type: 2,
               content: '/admin/common/order/follow?oid='+oid,
               area:['70%', '500px'],
           });
       });
    });
SCRIPT;
    }

    protected function render()
    {
        Admin::script($this->script());
        return "&nbsp;<a href='javascript:void(0);'><button  data-oid='{$this->oid}' data-name='{$this->name}' class='follow layui-btn layui-bg-green layui-btn-xs'>跟</button></a>";
    }

    public function __toString()
    {
        return $this->render();
    }
}